package testyGUI;

import static org.junit.Assert.*;

import java.io.IOException;

import gra.Account;
import gra.Card;
import gra.Human;
import gra.Player;
import gra.Table;

import org.junit.Test;

import GUI.Controler;
import GUI.VirtualPlayer;
import GUI.Wygrany;

public class WygranyTest 
{

    @Test
    public void test() throws IOException 
    {
        String[] nazwy = {"Adam", "Burek", "Karol" };
        boolean[] czyBot = { true, false, false };
        
        Table stol = new Table( 3, nazwy, czyBot, new Controler(), 1, 10 );
        VirtualPlayer[] players = new VirtualPlayer[3];
        //Account[] wygrani = new Account[3];
        
        stol.gracze[0] = new Account( new Human("G1"), 0, 0 );
        stol.gracze[1] = new Account( new Human("G2"), 0, 0 );
        stol.gracze[2] = new Account( new Human("G3"), 0, 0 );
        
        
        stol.gracze[0].hand[0] = new Card( 2, 1 );
        stol.gracze[0].hand[1] = new Card( 3, 1 );
        stol.gracze[0].hand[2] = new Card( 4, 1 );
        stol.gracze[0].hand[3] = new Card( 5, 1 );
        stol.gracze[0].hand[4] = new Card( 6, 1 );
        

        stol.gracze[1].hand[0] = new Card( 2, 2 );
        stol.gracze[1].hand[1] = new Card( 3, 2 );
        stol.gracze[1].hand[2] = new Card( 4, 2 );
        stol.gracze[1].hand[3] = new Card( 5, 2 );
        stol.gracze[1].hand[4] = new Card( 6, 2 );
        

        stol.gracze[2].hand[0] = new Card( 1, 1 );
        stol.gracze[2].hand[1] = new Card( 1, 2 );
        stol.gracze[2].hand[2] = new Card( 1, 3 );
        stol.gracze[2].hand[3] = new Card( 2, 3 );
        stol.gracze[2].hand[4] = new Card( 2, 0 );

        
        players[0] = new VirtualPlayer( stol.gracze[0] );
        players[1] = new VirtualPlayer( stol.gracze[1] );
        players[2] = new VirtualPlayer( stol.gracze[2] );
        
        Account[] winners = stol.computingGUI();
        assertNotNull(winners);
        
        System.out.println("Wygrany: ");
        for( int i = 0; i < winners.length; i++ )
        {
            System.out.println("Gracz: "+winners[i].owner.nazwa +", "+winners[i].figuraGracza() );
            assertEquals( "G"+(i+1), winners[i].owner.nazwa );
        }
        
        assertEquals( 2, winners.length );
        
        System.out.println( players[0].player.owner.nazwa );
        System.out.println( players[1].player.owner.nazwa );
        System.out.println( players[2].player.owner.nazwa );
        
        Wygrany winner   = new Wygrany( winners, players, players.length, new Controler() );
        assertNotNull(winner);
        
    }
    
}
